package com.example.parkingsharing.ui

import android.content.Context
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.navigation.compose.rememberNavController
import com.example.parkingsharing.MainActivity
import com.example.parkingsharing.data.mBottomTabItems
import com.example.parkingsharing.ui.navigation.BottomNavBar
import com.example.parkingsharing.ui.navigation.NavContent
import com.example.parkingsharing.ui.theme.ParkingSharingTheme
import com.google.accompanist.insets.ProvideWindowInsets
import com.google.accompanist.systemuicontroller.rememberSystemUiController

@Composable
fun ParkingSharingApp(
    modifier: Modifier = Modifier,
    context: MainActivity
) {
    val navHostController = rememberNavController()
    var bottomSelectedState by remember { mutableStateOf(0) }
    var isLogin by remember { mutableStateOf(false) }

    ParkingSharingTheme {
        ProvideWindowInsets {
            rememberSystemUiController().setStatusBarColor(
                Color.Transparent, darkIcons = MaterialTheme.colors.isLight
            )
            Surface(
                modifier = Modifier.fillMaxSize(),
                color = MaterialTheme.colors.background
            ) {
                Scaffold(
                    modifier = modifier,
                    bottomBar = {
                        BottomNavBar(
                            bottomSelectedState,
                            mBottomTabItems
                        ) { index, item ->
                            bottomSelectedState = index
                            navHostController.navigate(item.routeName)
                        }
                    },
                ) {
                    // 导航
                    NavContent(
                        navHostController,
                        modifier = Modifier.padding(it),
                        context = context,
                    )
                }
            }
        }
    }
}
